﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ValuationLogic;

namespace ValuationResource
{
    class swapTrade
    {
        public swapTrade()
        { }
        public swapTrade(Swap newSwap)
        {
            counterparty = newSwap.getCounterparty();
            buyFixed = (newSwap.isBuySwap() ? "BuyFixed" : "SellFixed");
            quantity = newSwap.getQuantity();
            fixedPrice = newSwap.getFixedPrice();
            periodStartDate = newSwap.getPeriodStartDate().Year.ToString() + "-" + newSwap.getPeriodStartDate().Month.ToString() + "-" + newSwap.getPeriodStartDate().Day.ToString();
            periodEndDate = newSwap.getPeriodEndDate().Year.ToString() + "-" + newSwap.getPeriodEndDate().Month.ToString() + "-" + newSwap.getPeriodEndDate().Day.ToString();
            quoteCode = newSwap.getQuoteCode();
            //riskExposures = Math.Round(newSwap.calRiskExposure(current));
            //riskExposures = Math.Round(Logic.calSwapRiskexposure(newSwap),3);
            if (Logic.calSwap(newSwap))
            {
                PNL = Convert.ToDouble(newSwap.getPnL()).ToString("0.00");
            }
            else
            {
                PNL = "--";
            }
            riskExposures = Convert.ToDouble(newSwap.getRiskExposure()).ToString("0.00");
            //PNL = Math.Round(newSwap.calPnL(current),3);
            //PNL = Math.Round(Logic.clickPnL(newSwap),3);
        }
        public Swap update(Swap newSwap)
        {
            if (Logic.calSwap(newSwap))
            {
                PNL = Convert.ToDouble(newSwap.getPnL()).ToString("0.00");
            }
            else
            {
                PNL = "--";
            }
            riskExposures =Convert.ToDouble(newSwap.getRiskExposure()).ToString("0.00");
	    return newSwap;
            //riskExposures = Math.Round(newSwap.calRiskExposure(current));
            //riskExposures = Math.Round(Logic.calSwapRiskexposure(newSwap), 3);
            //PNL = Math.Round(Logic.clickPnL(newSwap), 3);
        }
        public string counterparty { set; get; }
        public string buyFixed { set; get; }
        public double quantity { set; get; }
        public string dealDate { set; get; }
        public double fixedPrice { set; get; }
        public string periodStartDate { set; get; }
        public string periodEndDate { set; get; }
        public string quoteCode { set; get; }
        public string riskExposures { set; get; }
        public string PNL { set; get; }
    }
}
